package com.sky.listeners;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author 衷岚
 * @version 1.0
 */
@Component
@Slf4j
public class MqListener {


    //@RabbitListener(queues = "q1")
    public void listenerSimpleMQ1(String msg) throws InterruptedException {
        System.out.println("消费者1 接收队q1的消息："+msg);
        Thread.sleep(20);

    }
    //@RabbitListener(queues = "q1")
    public void listenerSimpleMQ2(String msg) throws InterruptedException {
        System.err.println("消费者2 接收队列q1消息："+msg);
        Thread.sleep(200);

    }

    /**
     * 测试 处理失败重试机制
     * @param msg
     *
     */
    @RabbitListener(queues = "q1")
    public void listenerSimpleMQ3(String msg)  {
        System.out.println("消费者1 接收队q1的消息："+msg);

        throw new RuntimeException("故意的...");
    }
}
